<!DOCTYPE HTML>
<html th:with="title='编辑商品投放记录',module='/js/app/common/uploadaudio.js'">
<head th:include="fragments/header :: header">
</head>
<body id="app">
	<div class="page-container">
		<form action="/manager/deviceproductrecord/update" method="post" class="form form-horizontal" id="deviceproductrecord-form">
			<input type="hidden" name="id" v-model="id" />
			<div class="row cl">
				<label class="form-label col-xs-4 col-sm-3">
					<span class="c-red">*</span>
					商品名称：
				</label>
				<div class="formControls col-xs-3 col-sm-3">
					<input type="text" class="input-text size-L" v-model="product.name" id="product.name" name="product.name" readonly="readonly">
				</div>
			</div>
			<div class="row cl">
				<label class="form-label col-xs-4 col-sm-3">
					<span class="c-red">*</span>
					设备编码：
				</label>
				<div class="formControls col-xs-3 col-sm-3">
					<input type="text" class="input-text size-L" v-model="device.sn" id="device.sn" name="device.sn" readonly="readonly">
				</div>
			</div>
			<div class="row cl">
				<label class="form-label col-xs-4 col-sm-3">投放时间：</label>
				<div class="formControls col-xs-4 col-sm-4">
					<input type="text" class="input-text size-L laydate-icon" th:value="${lastDay}" style="width: 100px;" onclick="laydate({istime: true, format: 'YYYY-MM-DD hh:mm:ss', start: laydate.now(-1),  min: laydate.now(-180), max: laydate.now(30)})" id="daybegin" name="startTime" v-model="red.startTime">
					-
					<input type="text" class="input-text size-L laydate-icon" th:value="${lastDay}" style="width: 100px;" onclick="laydate({istime: true, format: 'YYYY-MM-DD hh:mm:ss', start: laydate.now(-1),  min: laydate.now(-180), max: laydate.now(30)})" id="dayend" name="endTime" v-model="red.endTime">
				</div>
			</div>
			<div class="row cl">
				<label class="form-label col-xs-4 col-sm-3">关联用户：</label>

				<div class="formControls col-xs-3 col-sm-3">
					<input type="text" class="input-text size-L" id="userName" name="userName" v-model="user.name" readonly="readonly">
					<input type="hidden" id="operator" name="operator" v-model="user.id">
				</div>
				<div class="formControls col-xs-1 col-sm-1">
					<input class="btn btn-link" type="button" onclick="showMenu();" value="选择">
				</div>
			</div>
			<div class="row cl">
				<label class="form-label col-xs-4 col-sm-3">
					<span class="c-red">*</span>
					备注：
				</label>
				<div class="formControls col-xs-3 col-sm-3">
					<input type="text" class="input-text size-L" v-model="remark" id="remark" name="remark">
				</div>
			</div>
			<div class="row cl">
				<div class="text-c">
					<input class="btn btn-primary size-L radius mr-10" type="submit" value="提交">
					<input class="btn btn-danger size-L radius" type="button" onclick="closeWin()" value="关闭">
				</div>
			</div>
		</form>
	</div>

	<div th:include="fragments/widget :: userTreePanel"></div>
	<script th:include="fragments/widget :: userTreeJs" type="text/javascript">
		
	</script>
	<script type="text/javascript">
		function get() {
			var id = getIdFromUrl();
			$.ajax({
				type : "GET",
				url : '/manager/deviceadsrecord/get/' + id,
				beforeSend : function() {
				},
				complete : function() {
				},
				error : function(request) {
					alert("Connection error");
				},
				success : function(result) {
					if (result.status == 0) {
						var data = result.data;
						new Vue({
							el : '#deviceproductrecord-form',
							data : data
						});

					}
				}
			});
		}

		$(function() {
			$('#multuserIds').multiselect({
				submitAllLeft : false,
				submitAllRight : false
			});
			get();
			$("#deviceproductrecord-form").validate({
				rules : {
					name : {
						required : true,
						minlength : 2,
						maxlength : 16
					},
					remark : {
						required : false,
						minlength : 2,
						maxlength : 16
					}
				},
				onkeyup : false,
				focusCleanup : true,
				success : "valid",
				submitHandler : function(form) {
					var data = $('#deviceproductrecord-form').serialize();

					if ($("#operator").val() != "") {
						data += "&user.id=" + $("#operator").val();
					}

					$.ajax({
						type : "POST",
						url : '/manager/deviceadsrecord/update',
						data : data,
						beforeSend : function() {

						},
						complete : function() {

						},
						error : function(request) {
							layer.alert("系统出错");
						},
						success : function(data) {
							if (data.status == 0) {
								refreshUParentList();
								layer.alert(data.message, function() {
									var index = parent.layer.getFrameIndex(window.name);
									parent.layer.close(index);
								});
							} else {
								layer.alert(data.message);
							}
						}
					});
				}
			});
		});
	</script>
</body>
</html>